package com.badlogic.androidgames.donkeynator;

import android.graphics.Bitmap;


/**
 * The WorldRenderer class takes a World instance and draws
 * its current state with the help of a Game instance.
*/
public class WorldRenderer {
    com.badlogic.androidgames.framework.Game game;
    World world;
    Bitmap ballImage;
    Bitmap paddleImage;
    Bitmap blocksImage;
    
    public WorldRenderer(com.badlogic.androidgames.framework.Game game, World world) {
        this.game = game;
        this.world = world;
        this.ballImage = game.loadBitmap("banana.png");
        this.paddleImage = game.loadBitmap("big_monkey.png");
        this.blocksImage = game.loadBitmap("small_monkey.png");
    }
    
    public void render() {
        game.drawBitmap(ballImage, (int)world.ball.x, (int)world.ball.y);
        game.drawBitmap(paddleImage, (int)world.paddle.x, (int)world.paddle.y);
        
        for(int i = 0; i < world.blocks.size(); i++) {
            Block block = world.blocks.get(i);
            game.drawBitmap(blocksImage, (int)block.x, (int)block.y,
                            0, (int)(block.type * Block.HEIGHT),
                            (int)Block.WIDTH, (int)Block.HEIGHT);
        }
    }       
}
